/*
 * author      : 吴中勤 
 * date        : 2019/1/6
 * description : TODO
 */


import java.util.ArrayList;
import java.util.List;

public class UseJConsole {

    private static class OOMObject {
        private byte[] _1MB = new byte[64 * 1024];
    }

    private static void fill(int count) throws InterruptedException {
        List<OOMObject> objList = new ArrayList<>();

        for(int i=0; i < count; i++) {
            Thread.sleep(20);
            objList.add(new OOMObject());
        }
//        System.out.println("gc");
//        System.gc();
    }

    public static void main(String[] args){
        try {
            fill(1000);
            System.out.println("gc");
            System.gc();

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}